package com.catchu.pattern.creational.适配器模式.基于对象;

/**
 * 用户管理适配器
 */
public class UserManageAdapter implements UserManageInterface {

    private UserOperation userOperation = new UserOperation();

    @Override
    public Integer addUser(String name) {
        if(userOperation.getSnByName(name)>0){
            throw new RuntimeException("用户已存在，添加用户失败");
        }

        if(!userOperation.insertUser(name)){
            throw new RuntimeException("添加用户失败");
        }

        return userOperation.getSnByName(name);
    }
}
